<?php
/**
 * Created by PhpStorm.
 * User: tri
 * Date: 7/30/2014
 * Time: 3:10 PM
 */

require_once('../../class_ajax_request/classAjax.php');
include_once('../../application/functions.php');
include_once('../../application/DataConfig.php');

$idPost = $key['id'];
$obj      = new AjaxRequest();

$voters = $obj->getVoter($idPost);
$sexCount = $obj->getStatSexVoter($idPost);
$ageCount = $obj->getStatAgeVoter($idPost);

$sexCount['male'] = isset($sexCount['male'])?$sexCount['male']:0;
$sexCount['female'] = isset($sexCount['female'])?$sexCount['female']:0;
$datatext = '["male", '.$sexCount['male'].'],
     ["female", '.$sexCount['female'].']
';


//sex chart
$html_sex = $obj->renderPieChart($datatext,$idPost,'staticsSexPost',array('title'=>'Gender'));


//birthChart
$child = isset($ageCount['children'])?$ageCount['children']:0;
$teen= isset($ageCount['teens'])?$ageCount['teens']:0;
$youth= isset($ageCount['youth'])?$ageCount['youth']:0;
$youngAdults = isset($ageCount['young-adults'])?$ageCount['young-adults']:0;
$adults = isset($ageCount['adults'])?$ageCount['adults']:0;
$senior = isset($ageCount['senior'])?$ageCount['senior']:0;


$databirthtext  = ' ["Children", '.$child.'],
                    ["Teens ", '.$teen.'],
                    ["Youth ", '.$youth.'],
                    ["Young ", '.$youngAdults.'],
                    ["Adults", '.$adults.'],
                    ["Senior ", '.$senior.']';
$html_birth = $obj->renderPieChart($databirthtext,$idPost,'staticsBirthPost',array('title'=>'Age'));


echo '<div class="stat-col">';
echo '    <div class="col-lg-6">'.$html_sex.'</div>';
echo '    <div class="col-lg-6">'.$html_birth.'</div>';
echo '</div>';
//echo strtotime('09/20/1989');
//echo '<pre>';
//print_r($ageCount);
//echo '</pre>';


